/*
 * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
 * Copyright (C) 2019 XiaoMi, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

&soc {
	led_flash0: qcom,camera-flash@0 {
		cell-index = <0>;
		compatible = "qcom,camera-flash";
		qcom,flash-source = <&pm660l_flash0 &pm660l_flash1>;
		qcom,torch-source = <&pm660l_torch0 &pm660l_torch1>;
		qcom,switch-source = <&pm660l_switch0>;
		status = "ok";
	};

	led_flash1: qcom,camera-flash@1 {
		cell-index = <1>;
		compatible = "qcom,camera-flash";
		qcom,flash-source = <&pm660l_flash2>;
		qcom,torch-source = <&pm660l_torch2>;
		qcom,switch-source = <&pm660l_switch1>;
		status = "disable";
	};

	vaf_gpio_supply: vaf_gpio_supply {
		compatible = "regulator-fixed";
		regulator-name = "vaf_gpio_supply";
		regulator-min-microvolt = <2800000>;
		regulator-max-microvolt = <2800000>;
		startup-delay-us = <4000>;
		enable-active-high;
		gpio = <&tlmm 50 0>;
	};

	vdig_gpio_supply: vdig_gpio_supply {
		compatible = "regulator-fixed";
		regulator-name = "vdig_gpio_supply";
		regulator-min-microvolt = <1350000>;
		regulator-max-microvolt = <1350000>;
		startup-delay-us = <4000>;
		enable-active-high;
		gpio = <&pm660l_gpios 4 0>;
		pinctrl-names = "default";
		pinctrl-0 = <&cam_sensor_eldo4_default>;
	};

	vana_gpio_supply: vana_gpio_supply {
		compatible = "regulator-fixed";
		regulator-name = "vana_gpio_supply";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		startup-delay-us = <4000>;
		enable-active-high;
		gpio = <&tlmm 51 0>;
	};
};

&cci {
	actuator0: qcom,actuator@0 {
		cell-index = <0>;
		reg = <0x0>;
		compatible = "qcom,actuator";
		qcom,cci-master = <0>;
		cam_vaf-supply = <&vaf_gpio_supply>;
		cam_vio-supply = <&pm660_l14>;
		qcom,cam-vreg-name = "cam_vaf", "cam_vio";
		qcom,cam-vreg-min-voltage = <2800000 1780000>;
		qcom,cam-vreg-max-voltage = <2800000 1950000>;
		qcom,cam-vreg-op-mode = <100000 105000>;
	};

	actuator1: qcom,actuator@1 {
		cell-index = <1>;
		reg = <0x1>;
		compatible = "qcom,actuator";
		qcom,cci-master = <1>;
		cam_vaf-supply = <&vaf_gpio_supply>;
		cam_vio-supply = <&pm660_l14>;
		qcom,cam-vreg-name = "cam_vaf","cam_vio";
		qcom,cam-vreg-min-voltage = <2800000 1780000>;
		qcom,cam-vreg-max-voltage = <2800000 1950000>;
		qcom,cam-vreg-op-mode = <100000 105000>;
	};

	ois0: qcom,ois@0 {
		cell-index = <0>;
		reg = <0x0>;
		compatible = "qcom,ois";
		qcom,cci-master = <0>;
		cam_vaf-supply = <&vaf_gpio_supply>;
		qcom,cam-vreg-name = "cam_vaf";
		qcom,cam-vreg-min-voltage = <2800000>;
		qcom,cam-vreg-max-voltage = <2800000>;
		qcom,cam-vreg-op-mode = <100000>;
	};

	eeprom0: qcom,eeprom@0 {
		cell-index = <0>;
		reg = <0>;
		//qcom,eeprom-name = <"jason_imx386_semco">;
		compatible = "qcom,eeprom";
		qcom,slave-addr = <0xa0>;
		qcom,i2c-freq-mode = <1>;
		qcom,num-blocks = <2>;
		qcom,page0 = <0 0 0 0 0 0>;
		qcom,poll0 = <0 0 0 0 0 0>;
		qcom,mem0 = <4960 0x00 2 0 1 0>;
		qcom,page1 = <0 0 0 0 0 0>;
		qcom,poll1 = <0 0 0 0 0 0>;
		qcom,mem1 = <2064 0x1360 2 0 1 0>;
		cam_vio-supply = <&pm660_l14>;
		qcom,cam-vreg-name = "cam_vio";
		qcom,cam-vreg-min-voltage = <0>;
		qcom,cam-vreg-max-voltage = <0>;
		qcom,cam-vreg-op-mode = <0>;
		qcom,cam-power-seq-type = "sensor_vreg";
		qcom,cam-power-seq-val = "cam_vio";
		qcom,cam-power-seq-cfg-val = <1>;
		qcom,cam-power-seq-delay = <1>;
		qcom,gpio-no-mux = <0>;
		pinctrl-names = "cam_default", "cam_suspend";
		pinctrl-0 = <&cam_sensor_mclk0_active_jason
				&cam_sensor_rear_active>;
		pinctrl-1 = <&cam_sensor_mclk0_suspend_jason
				&cam_sensor_rear_suspend>;
		gpios = <&tlmm 32 0>,
			<&tlmm 46 0>;
		qcom,gpio-reset = <1>;
		qcom,gpio-req-tbl-num = <0 1>;
		qcom,gpio-req-tbl-flags = <1 0>;
		qcom,gpio-req-tbl-label = "CAMIF_MCLK0",
					"CAM_RESET0";
		qcom,sensor-position = <0>;
		qcom,sensor-mode = <0>;
		qcom,cci-master = <0>;
		status = "ok";
		clocks = <&clock_mmss MCLK0_CLK_SRC>,
				<&clock_mmss MMSS_CAMSS_MCLK0_CLK>;
		clock-names = "cam_src_clk", "cam_clk";
		qcom,clock-rates = <24000000 0>;
	};

	eeprom1: qcom,eeprom@1 {
		cell-index = <1>;
		reg = <1>;
		//qcom,eeprom-name = "jason_s5k3m3_semco";
		compatible = "qcom,eeprom";
		qcom,slave-addr = <0xa0>;
		qcom,i2c-freq-mode = <1>;
		qcom,num-blocks = <2>;
		qcom,page0 = <0 0 0 0 0 0>;
		qcom,poll0 = <0 0 0 0 0 0>;
		qcom,mem0 = <4960 0x00 2 0 1 0>;
		qcom,page1 = <0 0 0 0 0 0>;
		qcom,poll1 = <0 0 0 0 0 0>;
		qcom,mem1 = <2064 0x1360 2 0 1 0>;
		cam_vio-supply = <&pm660_l14>;
		qcom,cam-vreg-name = "cam_vio";
		qcom,cam-vreg-min-voltage = <0>;
		qcom,cam-vreg-max-voltage = <0>;
		qcom,cam-vreg-op-mode = <0>;
		qcom,cam-power-seq-type = "sensor_vreg";
		qcom,cam-power-seq-val = "cam_vio";
		qcom,cam-power-seq-cfg-val = <1>;
		qcom,cam-power-seq-delay = <1>;
		qcom,gpio-no-mux = <0>;
		pinctrl-names = "cam_default", "cam_suspend";
		pinctrl-0 = <&cam_sensor_mclk0_active_jason
				&cam_sensor_rear_active>;
		pinctrl-1 = <&cam_sensor_mclk0_suspend_jason
				&cam_sensor_rear_suspend>;
		gpios = <&tlmm 32 0>,
			<&tlmm 46 0>;
		qcom,gpio-reset = <1>;
		qcom,gpio-req-tbl-num = <0 1>;
		qcom,gpio-req-tbl-flags = <1 0>;
		qcom,gpio-req-tbl-label = "CAMIF_MCLK0",
					"CAM_RESET0";
		qcom,sensor-position = <0>;
		qcom,sensor-mode = <0>;
		qcom,cci-master = <0>;
		status = "ok";
		clocks = <&clock_mmss MCLK0_CLK_SRC>,
				<&clock_mmss MMSS_CAMSS_MCLK0_CLK>;
		clock-names = "cam_src_clk", "cam_clk";
		qcom,clock-rates = <24000000 0>;
	};

	eeprom2: qcom,eeprom@2 {
		cell-index = <2>;
		reg = <2>;
		//qcom,eeprom-name = "jason_s5k3p8sp_sunny";
		compatible = "qcom,eeprom";
		qcom,slave-addr = <0xa0>;
		qcom,i2c-freq-mode = <1>;
		qcom,num-blocks = <1>;
		qcom,page0 = <0 0 0 0 0 0>;
		qcom,poll0 = <0 0 0 0 0 0>;
		qcom,mem0 = <7494 0x00 2 0 1 0>;
		cam_vio-supply = <&pm660_l14>;
		qcom,cam-vreg-name = "cam_vio";
		qcom,cam-vreg-min-voltage = <0>;
		qcom,cam-vreg-max-voltage = <0>;
		qcom,cam-vreg-op-mode = <0>;
		qcom,cam-power-seq-type = "sensor_vreg";
		qcom,cam-power-seq-val = "cam_vio";
		qcom,cam-power-seq-cfg-val = <1>;
		qcom,cam-power-seq-delay = <1>;
		qcom,gpio-no-mux = <0>;
		pinctrl-names = "cam_default", "cam_suspend";
		pinctrl-0 = <&cam_sensor_mclk1_active
				 &cam_sensor_front_active_jason
				 &cam_sensor_eldo3_default>;
		pinctrl-1 = <&cam_sensor_mclk1_suspend
				 &cam_sensor_front_suspend>;
		gpios = <&tlmm 33 0>,
			<&tlmm 44 0>,
			<&tlmm 47 0>,
			<&tlmm 49 0>,
			<&pm660l_gpios 3 0>;
		qcom,gpio-standby = <1>;
		qcom,gpio-reset = <2>;
		qcom,gpio-vana = <3>;
		qcom,gpio-vdig = <4>;
		qcom,gpio-req-tbl-num = <0 1 2 3 4>;
		qcom,gpio-req-tbl-flags = <1 0 0 0 0>;
		qcom,gpio-req-tbl-label = "CAMIF_MCLK1",
					"CAM_STANDBY1",
					"CAM_RESET1",
					"CAM_VANA",
					"CAM_VDIG";
		qcom,sensor-position = <1>;
		qcom,sensor-mode = <0>;
		qcom,cci-master = <1>;
		status = "ok";
		clocks = <&clock_mmss MCLK1_CLK_SRC>,
			<&clock_mmss MMSS_CAMSS_MCLK1_CLK>;
		clock-names = "cam_src_clk", "cam_clk";
		qcom,clock-rates = <24000000 0>;

	};

	qcom,camera@0 {
		cell-index = <0>;
		compatible = "qcom,camera";
		reg = <0x0>;
		qcom,csiphy-sd-index = <0>;
		qcom,csid-sd-index = <0>;
		qcom,mount-angle = <90>;
		qcom,led-flash-src = <&led_flash0>;
		qcom,actuator-src = <&actuator0>;
		qcom,eeprom-src = <&eeprom0>;
		qcom,ois-src = <&ois0>;
		cam_vio-supply = <&pm660_l14>;
		cam_vana-supply = <&pm660l_bob>;
		cam_vdig-supply = <&pm660_s5>;
		cam_v_custom1-supply = <&vdig_gpio_supply>;
		cam_v_custom2-supply =<&vana_gpio_supply>;
		qcom,cam-vreg-name = "cam_vio", "cam_vana", "cam_vdig", "cam_v_custom1", "cam_v_custom2";
		qcom,cam-vreg-min-voltage = <1780000 3300000 1350000 1350000 3300000>;
		qcom,cam-vreg-max-voltage = <1950000 3600000 1350000 1350000 3300000>;
		qcom,cam-vreg-op-mode = <105000 80000 105000 105000 80000>;
		qcom,gpio-no-mux = <0>;
		pinctrl-names = "cam_default", "cam_suspend";
		pinctrl-0 = <&cam_sensor_mclk0_active_jason
				 &cam_sensor_rear_active>;
		pinctrl-1 = <&cam_sensor_mclk0_suspend_jason
				 &cam_sensor_rear_suspend>;
		gpios = <&tlmm 32 0>,
			<&tlmm 46 0>;
		qcom,gpio-reset = <1>;
		qcom,gpio-req-tbl-num = <0 1>;
		qcom,gpio-req-tbl-flags = <1 0>;
		qcom,gpio-req-tbl-label = "CAMIF_MCLK0",
					"CAM_RESET0";
		qcom,sensor-position = <0>;
		qcom,sensor-mode = <0>;
		qcom,cci-master = <0>;
		status = "ok";
		clocks = <&clock_mmss MCLK0_CLK_SRC>,
				<&clock_mmss MMSS_CAMSS_MCLK0_CLK>;
		clock-names = "cam_src_clk", "cam_clk";
		qcom,clock-rates = <24000000 0>;
	};

	qcom,camera@1 {
		cell-index = <1>;
		compatible = "qcom,camera";
		reg = <0x1>;
		qcom,csiphy-sd-index = <1>;
		qcom,csid-sd-index = <1>;
		qcom,mount-angle = <90>;
		qcom,led-flash-src = <&led_flash0>;
		qcom,actuator-src = <&actuator1>;
		qcom,eeprom-src = <&eeprom1>;
		cam_vio-supply = <&pm660_l14>;
		cam_vana-supply = <&pm660l_bob>;
		cam_vdig-supply = <&pm660_s5>;
		cam_v_custom1-supply = <&vdig_gpio_supply>;
		cam_v_custom2-supply = <&vana_gpio_supply>;
		qcom,cam-vreg-name = "cam_vio", "cam_vana", "cam_vdig", "cam_v_custom1", "cam_v_custom2";
		qcom,cam-vreg-min-voltage = <1780000 3300000 1350000 1350000 3300000>;
		qcom,cam-vreg-max-voltage = <1950000 3600000 1350000 1350000 3300000>;
		qcom,cam-vreg-op-mode = <105000 80000 105000 105000 80000>;
		qcom,gpio-no-mux = <0>;
		pinctrl-names = "cam_default", "cam_suspend";
		pinctrl-0 = <&cam_sensor_mclk3_active
				 &cam_sensor_front_iris_active>;
		pinctrl-1 = <&cam_sensor_mclk3_suspend
				 &cam_sensor_front_iris_suspend>;
		gpios = <&tlmm 35 0>,
			<&tlmm 52 0>;
		qcom,gpio-reset = <1>;
		qcom,gpio-req-tbl-num = <0 1>;
		qcom,gpio-req-tbl-flags = <1 0>;
		qcom,gpio-req-tbl-label = "CAMIF_MCLK3",
					  "CAM_RESET3";
		qcom,sensor-position = <0>;
		qcom,sensor-mode = <0>;
		qcom,cci-master = <1>;
		status = "ok";
		clocks = <&clock_mmss MCLK3_CLK_SRC>,
			<&clock_mmss MMSS_CAMSS_MCLK3_CLK>;
		clock-names = "cam_src_clk", "cam_clk";
		qcom,clock-rates = <24000000 0>;
	};

	qcom,camera@2 {
		cell-index = <2>;
		compatible = "qcom,camera";
		reg = <0x02>;
		qcom,csiphy-sd-index = <2>;
		qcom,csid-sd-index = <2>;
		qcom,mount-angle = <270>;
		qcom,eeprom-src = <&eeprom2>;
		cam_vio-supply = <&pm660_l14>;
		cam_vana-supply = <&pm660l_bob>;
		cam_vdig-supply = <&pm660_s5>;
		qcom,cam-vreg-name = "cam_vio", "cam_vana", "cam_vdig";
		qcom,cam-vreg-min-voltage = <1780000 3300000 1350000>;
		qcom,cam-vreg-max-voltage = <1950000 3600000 1350000>;
		qcom,cam-vreg-op-mode = <105000 80000 105000>;
		qcom,gpio-no-mux = <0>;
		pinctrl-names = "cam_default", "cam_suspend";
		pinctrl-0 = <&cam_sensor_mclk1_active
				 &cam_sensor_front_active_jason>;
		pinctrl-1 = <&cam_sensor_mclk1_suspend
				 &cam_sensor_front_suspend>;
		gpios = <&tlmm 33 0>,
			<&tlmm 44 0>,
			<&tlmm 47 0>,
			<&tlmm 49 0>,
			<&pm660l_gpios 3 0>;
		qcom,gpio-standby = <1>;
		qcom,gpio-reset = <2>;
		qcom,gpio-vana = <3>;
		qcom,gpio-vdig = <4>;
		qcom,gpio-req-tbl-num = <0 1 2 3 4>;
		qcom,gpio-req-tbl-flags = <1 0 0 0 0>;
		qcom,gpio-req-tbl-label = "CAMIF_MCLK1",
					"CAM_STANDBY1",
					"CAM_RESET1",
					"CAM_VANA",
					"CAM_VDIG";
		qcom,sensor-position = <1>;
		qcom,sensor-mode = <0>;
		qcom,cci-master = <1>;
		status = "ok";
		clocks = <&clock_mmss MCLK1_CLK_SRC>,
			<&clock_mmss MMSS_CAMSS_MCLK1_CLK>;
		clock-names = "cam_src_clk", "cam_clk";
		qcom,clock-rates = <24000000 0>;
	};
};

&pm660l_gpios {
	cam_sensor_eldo3 {
		cam_sensor_eldo3_default: cam_sensor_eldo3_default {
			pins = "gpio3";
			function = "normal";
			output-high;
			bias-disable;
		};
	};
	cam_sensor_eldo4 {
		cam_sensor_eldo4_default: cam_sensor_eldo4_default {
			pins = "gpio4";
			function = "normal";
			output-low;
			bias-disable;
		};
	};
};
